<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
	</head>
	<body>
		<button onclick="foo()">隔10s关闭页面</button>
				
				<button onclick="foo2()" id="btn2">倒数10s</button>
				<script>
					

					function foo()
					{
						setTimeout(function(){
							close();
						},10000);
					}
					
					var n = 10;
					function foo2()
					{
						if(n>0)
						{
							n = n - 1
							btn2.textContent = "倒数"+n+"s";
							setTimeout(foo2,1000);
						}
					}
				</script>
	</body>
</html>